package com.system.provider;

import com.am.ui.grid.AbstractBaseGridProvider;
import com.system.uitls.CommonUtil;
import com.system.uitls.SearchFilter;
import java.util.Map;

public class RegisterListProvider extends AbstractBaseGridProvider
{
  public String generateSql(Map<String, Object> map)
  {
    String toDay = CommonUtil.getFormatCurDate("yyyy-MM-dd");
    String flag = CommonUtil.nullToEmptyString(map.get("flag"));
    StringBuffer sql = new StringBuffer("SELECT r.id,r.register_name,r.create_time,r.register_charge,r.book_amount,r.create_user_id,r.create_user_name,r.status,r.back_reason,r.amount,p.sex FROM sys_register AS r,sys_person AS p WHERE 1=1 AND r.register_id = p.id AND r.person_campus=:campus");

    if ("0".equals(flag))
    {
      sql.append(" AND convert(char(10),r.create_time,120)='").append(toDay).append("'");
    }

    sql.append(SearchFilter.getSearchSql(map, null));

    sql.append(" ORDER BY create_time desc");
    setParamMap(map);

    return sql.toString();
  }
}